-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Use pre-order stages ordering in EXPLAN output #26655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use pre-order stages ordering in EXPLAN output #26655
Conversation
testing/trino-benchmark-queries/src/main/resources/sql/trino/tpch/q17.sql
Show resolved
Hide resolved
7b5b5de to
b94e6fc
Compare
|
This pull request has gone a while without any activity. Ask for help on #core-dev on Trino slack. |
|
@losipiuk ready for review? |
b94e6fc to
605de60
Compare
Rename getSubStagesDeepPreOrder to getSubStagesDeep. Call spots did not really depend on any specific ordering of returned stages.
605de60 to
0782d71
Compare
Reviewer's GuideThis PR refactors StagesInfo to replace the specialized pre- and post-order traversals with unified getSubStagesDeep (pre-order) and getSubStagesDeepTopological (topological) methods and updates all consumer code—ExplainAnalyzeOperator, QueryMonitor, and PlanPrinter—to use the new APIs, ensuring that EXPLAIN output uses a consistent pre-order stage ordering. Sequence diagram for finding failed tasks in QueryMonitor using new traversalsequenceDiagram
participant QueryMonitor
participant StagesInfo
participant StageInfo
participant TaskInfo
participant TaskStatus
QueryMonitor->>StagesInfo: getSubStagesDeep(outputStageId, true)
loop for each StageInfo
StagesInfo-->>QueryMonitor: StageInfo
QueryMonitor->>StageInfo: getTasks()
loop for each TaskInfo
StageInfo-->>QueryMonitor: TaskInfo
QueryMonitor->>TaskInfo: taskStatus()
TaskInfo-->>QueryMonitor: TaskStatus
QueryMonitor->>TaskStatus: getState()
TaskStatus-->>QueryMonitor: TaskState
end
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes - here's some feedback:
- In findFailedTask you’ve switched from post-order to pre-order traversal, which may report a different failed task than before—double-check that this still aligns with the intended deepest-first behavior.
- The private helper collectSubStageIdsPreOrder is now used for generic deep traversal but still named “PreOrder”—consider renaming it (and its parameters) to better reflect its updated purpose.
- The topological traversal builds the list then calls reverse; you could simplify by adding elements in reverse order during the walk to avoid the extra reverse step.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In findFailedTask you’ve switched from post-order to pre-order traversal, which may report a different failed task than before—double-check that this still aligns with the intended deepest-first behavior.
- The private helper collectSubStageIdsPreOrder is now used for generic deep traversal but still named “PreOrder”—consider renaming it (and its parameters) to better reflect its updated purpose.
- The topological traversal builds the list then calls reverse; you could simplify by adding elements in reverse order during the walk to avoid the extra reverse step.
## Individual Comments
### Comment 1
<location> `core/trino-main/src/main/java/io/trino/execution/StagesInfo.java:136` </location>
<code_context>
- collectSubStageIdsPostOrder(stageInfo, subStagesIds);
- if (includeRoot) {
- subStagesIds.add(root);
+ if (visitedFragments.contains(stageId)) {
+ return;
}
</code_context>
<issue_to_address>
**question:** Cycle detection is introduced but not documented.
Using 'visitedFragments' avoids infinite recursion, but if cycles are unexpected, this could hide data problems. Consider raising an error or warning when a cycle is detected.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| collectSubStageIdsPostOrder(stageInfo, subStagesIds); | ||
| if (includeRoot) { | ||
| subStagesIds.add(root); | ||
| if (visitedFragments.contains(stageId)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Cycle detection is introduced but not documented.
Using 'visitedFragments' avoids infinite recursion, but if cycles are unexpected, this could hide data problems. Consider raising an error or warning when a cycle is detected.
|
@losipiuk Could you update "Release notes" section? |
Description
Additional context and related issues
Release notes
(x) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text: